# Fudenberg, Gao & Liang 
# "How Flexible is that Functional Form? Quantifying the Restrictiveness of Theories"
# 
# Application 3: Microfinance Takeup

************
Files
************

R scripts (created based on R version 4.3.1):

"GenLinearData.R"
"GenNonlinearData.R"
"NetLinear.R"
"NetNonlinearComp.R"
"NetNnonlinearRest.R"

************
Guide
************

(1) Run the data extraction scripts "GenLinearData.R" and "GenNonlinearData.R" with the data folders "adj_all", "HHhasALeader" and "MF" in the working directory

	To replicate our results, 

	1.a) the folder "adj_all" should contain csv files named:
	
		adj_allVillageRelationships_HH_vilno_75.csv
		adj_allVillageRelationships_HH_vilno_1.csv
		adj_allVillageRelationships_HH_vilno_2.csv
		adj_allVillageRelationships_HH_vilno_3.csv
		adj_allVillageRelationships_HH_vilno_4.csv
		adj_allVillageRelationships_HH_vilno_6.csv
		adj_allVillageRelationships_HH_vilno_9.csv
		adj_allVillageRelationships_HH_vilno_12.csv
		adj_allVillageRelationships_HH_vilno_15.csv
		adj_allVillageRelationships_HH_vilno_19.csv
		adj_allVillageRelationships_HH_vilno_20.csv
		adj_allVillageRelationships_HH_vilno_21.csv
		adj_allVillageRelationships_HH_vilno_23.csv
		adj_allVillageRelationships_HH_vilno_24.csv
		adj_allVillageRelationships_HH_vilno_25.csv
		adj_allVillageRelationships_HH_vilno_29.csv
		adj_allVillageRelationships_HH_vilno_31.csv
		adj_allVillageRelationships_HH_vilno_32.csv
		adj_allVillageRelationships_HH_vilno_33.csv
		adj_allVillageRelationships_HH_vilno_36.csv
		adj_allVillageRelationships_HH_vilno_39.csv
		adj_allVillageRelationships_HH_vilno_42.csv
		adj_allVillageRelationships_HH_vilno_43.csv
		adj_allVillageRelationships_HH_vilno_45.csv
		adj_allVillageRelationships_HH_vilno_46.csv
		adj_allVillageRelationships_HH_vilno_47.csv
		adj_allVillageRelationships_HH_vilno_48.csv
		adj_allVillageRelationships_HH_vilno_50.csv
		adj_allVillageRelationships_HH_vilno_51.csv
		adj_allVillageRelationships_HH_vilno_52.csv
		adj_allVillageRelationships_HH_vilno_55.csv
		adj_allVillageRelationships_HH_vilno_57.csv
		adj_allVillageRelationships_HH_vilno_59.csv
		adj_allVillageRelationships_HH_vilno_60.csv
		adj_allVillageRelationships_HH_vilno_62.csv
		adj_allVillageRelationships_HH_vilno_64.csv
		adj_allVillageRelationships_HH_vilno_65.csv
		adj_allVillageRelationships_HH_vilno_67.csv
		adj_allVillageRelationships_HH_vilno_68.csv
		adj_allVillageRelationships_HH_vilno_70.csv
		adj_allVillageRelationships_HH_vilno_71.csv
		adj_allVillageRelationships_HH_vilno_72.csv
		adj_allVillageRelationships_HH_vilno_73.csv

	1.b) the folder "HHhasALeader" should contain csv files named:
	
		HHhasALeader1.csv
		HHhasALeader2.csv
		HHhasALeader3.csv
		HHhasALeader4.csv
		HHhasALeader6.csv
		HHhasALeader9.csv
		HHhasALeader12.csv
		HHhasALeader15.csv
		HHhasALeader19.csv
		HHhasALeader20.csv
		HHhasALeader21.csv
		HHhasALeader23.csv
		HHhasALeader24.csv
		HHhasALeader25.csv
		HHhasALeader29.csv
		HHhasALeader31.csv
		HHhasALeader32.csv
		HHhasALeader33.csv
		HHhasALeader36.csv
		HHhasALeader39.csv
		HHhasALeader42.csv
		HHhasALeader43.csv
		HHhasALeader45.csv
		HHhasALeader46.csv
		HHhasALeader47.csv
		HHhasALeader48.csv
		HHhasALeader50.csv
		HHhasALeader51.csv
		HHhasALeader52.csv
		HHhasALeader55.csv
		HHhasALeader57.csv
		HHhasALeader59.csv
		HHhasALeader60.csv
		HHhasALeader62.csv
		HHhasALeader64.csv
		HHhasALeader65.csv
		HHhasALeader67.csv
		HHhasALeader68.csv
		HHhasALeader70.csv
		HHhasALeader71.csv
		HHhasALeader72.csv
		HHhasALeader73.csv
		HHhasALeader75.csv
		
	1.c) the folder "MF" should contain csv files named:
	
		MF1.csv
		MF2.csv
		MF3.csv
		MF4.csv
		MF6.csv
		MF9.csv
		MF12.csv
		MF15.csv
		MF19.csv
		MF20.csv
		MF21.csv
		MF23.csv
		MF24.csv
		MF25.csv
		MF29.csv
		MF31.csv
		MF32.csv
		MF33.csv
		MF36.csv
		MF39.csv
		MF42.csv
		MF43.csv
		MF45.csv
		MF46.csv
		MF47.csv
		MF48.csv
		MF50.csv
		MF51.csv
		MF52.csv
		MF55.csv
		MF57.csv
		MF59.csv
		MF60.csv
		MF62.csv
		MF64.csv
		MF65.csv
		MF67.csv
		MF68.csv
		MF70.csv
		MF71.csv
		MF72.csv
		MF73.csv
		MF75.csv


(2) "NetLinear.R" computes the restrictiveness and completeness of the linear models, using "NetLinearData.RData" generated above.

(3) "NetNonlinearComp.R" computes the completeness of the partially linear model, using "NetNonlinearData.RData" generated above.

(4) "NetNnonlinearRest.R" computes the restrictiveness of the partially linear model, using "NetNonlinearData.RData" generated above.


************
Variable Names
************

The following village-level variable names in the R scripts correspond to the variables reported in the linear and partially linear models in Table 4.

mf_rate: microfinance take rate 

leader_eig: average eigenvector centrality of leaders

leaders_deg: average degree centrality of leaders

avg_deg: average degree centrality of all villagers

leaders_betweenness: average betweenness centrality of leaders

cluster_coeff: clustering coefficient of village network

avg_path_length: average path length in village network

comp_count: proportion of connected (non-isolated) villagers

leaders_rate: proportion of leaders

comp_lin: vector of estimated completeness of the linear models

se_comp_lin: standard error estimates for completeness of the linear models

rest_lin: vector of estimated restrictiveness for the linear models

se_rest_lin: standard error estimates for restrictiveness of the linear models

comp_nl: estimated completeness of the partially linear model

se_comp_lin: standard error estimate for completeness of the partially linear model

rest_nl: estimated restrictiveness for the partially linear model

se_rest_lin: standard error estimate for restrictiveness of the partially linear model

